package logic

import (
	"context"
	"homes/models"

	"homes/homesrpc/homesrpc"
	"homes/homesrpc/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type HouseListLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewHouseListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *HouseListLogic {
	return &HouseListLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *HouseListLogic) HouseList(in *homesrpc.HouseListRequest) (*homesrpc.HouseListResponse, error) {
	// todo: add your logic here and delete this line

	var house models.House
	var lists []*homesrpc.HouseList
	list, err := house.HouseList(models.DB, lists)
	if err != nil {
		return nil, err
	}

	return &homesrpc.HouseListResponse{
		List: list,
	}, nil
}
